# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=mibble
pkgver=2.10.1
pkgrel=1
pkgdesc='An open-source SNMP MIB parser (or SMI parser) written in Java. It can be used to read SNMP MIB files as well as simple ASN.1 files.'
url='https://github.com/cederberg/mibble/'
groups=('blackarch' 'blackarch-misc')
license=('GPL')
depends=('java-environment' 'bash')
arch=('any')
source=("https://github.com/cederberg/mibble/releases/download/v$pkgver/mibble-$pkgver.tar.gz")
sha512sums=('7d06ea48b1ee15cff82a54dffcc4e53ba5333e69275fd13bdfd2317afe7cd5a47fac94faa4e0eca32f6d4edda3aa71482390a7fdc01d836a4e2de6669cfc6fe0')

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  mv doc/api "$pkgdir/usr/share/doc/$pkgname/"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" doc/*
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf doc LICENSE.txt

  cp -a * "$pkgdir/usr/share/$pkgname"

  cat > "$pkgdir/usr/bin/mibblebrowser" << EOF
#!/bin/sh
cd /usr/share/$pkgname/bin/
exec ./MibbleBrowser.sh "\$@"
EOF

  cat > "$pkgdir/usr/bin/mibbleprinter" << EOF
#!/bin/sh
cd /usr/share/$pkgname/bin/
exec ./MibblePrinter.sh "\$@"
EOF

  cat > "$pkgdir/usr/bin/mibblevalidator" << EOF
#!/bin/sh
cd /usr/share/$pkgname/bin/
exec ./MibbleValidator.sh "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"*
}

